/*var EnumApps = {
	GONOGO_APP : {value : 0, name : "Decision", code : "D"}, 
	DECISION_APP : {value : 1, name : "Gonogo", code : "G"}, 
	WIKI_APP : {value : 2, name : "Wiki", code : "W"}, 
	FOP_APP : {value : 3, name : "Fop", code : "F"}, 
	LOG_APP : {value : 4, name : "Log", code : "L"}, 
	TM_APP : {value : 5, name : "TM", code : "T"}, 
	MOBILITY_APP : {value : 6, name : "Mob", code : "M"}
};
*/

var	GONOGO_APP = 0;
var	DECISION_APP = 1;
var	WIKI_APP = 2;
var	FOP_APP = 3; 
var	LOG_APP = 4;
var	TM_APP = 5;
var	MOBILITY_APP = 6;

var ENABLED = 1;
var DISABLED = 0;

function disconnect() {
	
 
/*	//Appel du script php
	$.ajax({
	type: "POST",
	url: "/Server/sessions.php",
	data: {
		maFonction : 'startSession'
	},

	success: function(data){	
		alert(data);*/
		
		//Appel du script php
		$.ajax({
		type: "POST",
		url: "/Server/sessions.php",
		data: {
			maFonction : 'stopSession'
		},

		success: function(data){	
			//alert(data);
			window.location = "/AMRA-SCC/MobilityAccess/WebContent/WEB-INF/connexionPage.html";
		},

		error: function(msg, string) {
			alert("Erreur : "+string);
		}
		});
/*	},

	error: function(msg, string) {
		alert("Erreur : "+string);
	}
	});*/
	

	return false;
}

function insertOpPage() {
	/*$.get("/AMRA-SCC/MobilityAccess/WebContent/WEB-INF/operationPage.html", function(data){
	    $('#content').html(data).trigger("create");
	});*/
	window.location="/AMRA-SCC/MobilityAccess/WebContent/WEB-INF/operationPage.html";
	return false;
}

function insertMonPage() {
	/*$.get("/AMRA-SCC/MobilityAccess/WebContent/WEB-INF/monitoringPage.html", function(data){
	    $('#content').html(data).trigger("create");
	});*/
	window.location="/AMRA-SCC/MobilityAccess/WebContent/WEB-INF/monitoringPage.html";
	return false;
}

function insertAdminPage() {
	window.location="/AMRA-SCC/MobilityAccess/WebContent/WEB-INF/addUserMobilityPage.html";
	return false;
}

function loadPage(url,element) {
	var droitsPage;
	//Appel du script php
	$.ajax({
	type: "POST",
	url: "/Server/sessions.php",
	data: {
		maFonction : 'startSession'
	},

	success: function(data){	

		if(element == "gonogo") {

			if(data[GONOGO_APP] == ENABLED) {
				window.location = url;
			}
			else document.getElementById('erreurGonogo').innerHTML = "Application not allowed";//alert('Houston we\'ve got a problem');
		
		} else if(element == "decisionmaking") {
				//droitsPage = "<?php echo json_encode($_SESSION['decisionR']); ?>";
				if(data[DECISION_APP] == ENABLED) {
					window.location = url;
				} else document.getElementById('erreurDecision').innerHTML = "Application not allowed";//alert('Houston we\'ve got a problem');
		} else if(element == "fop") {
				//droitsPage = "<?php echo $_SESSION['fopR']; ?>";
				if(data[FOP_APP] == ENABLED) {
					window.location = url;
				} else document.getElementById('erreurFop').innerHTML = "Application not allowed";//alert('Houston we\'ve got a problem');	
		}  else if(element == "wiki") {
				//droitsPage = "<?php echo $_SESSION['wikiR']; ?>";
				if(data[WIKI_APP] == ENABLED) {
					window.location = url;
				} else document.getElementById('erreurWiki').innerHTML = "Application not allowed";//alert('Houston we\'ve got a problem');	
		} else if(element == "tm") {
				//droitsPage = "<?php echo $_SESSION['tmR']; ?>";
				if(data[TM_APP] == ENABLED) {
					window.location = url;
				} else document.getElementById('erreurTm').innerHTML = "Application not allowed";//alert('Houston we\'ve got a problem');	
		} else if(element == "log") {
				//droitsPage = "<?php echo $_SESSION['logR']; ?>";
				if(data[LOG_APP] == ENABLED) {
					window.location = url;
				} else document.getElementById('erreurLog').innerHTML = "Application not allowed";//alert('Houston we\'ve got a problem');	
		} else {
			alert('Cas non prevu');
		}
	},

	error: function(msg, string) {
		alert("Erreur : "+string);
	}
	});


	
	return false;
}